package com.springboot.demo.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.springboot.demo.entity.validate.role.RoleNameGroup;
import com.springboot.demo.entity.validate.scene.*;
import com.springboot.demo.entity.validate.user.*;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.Value;
import org.hibernate.validator.constraints.Length;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.*;
import java.util.Date;
import java.util.List;

/**
 * @author wubc683
 * @desc
 * @date 2021-07-26 14:17
 */
@Data
@ApiModel
public class Scene {
    @ApiModelProperty(value = "组态id", required = true)
    @NotNull(message = "组态id不能为null", groups = IdGroup.class)
    private Long id;
    @ApiModelProperty(value = "组态文件所属分组文件夹的id,0表示未分组", required = true)
    @NotNull(message = "组态分组id不能为null", groups = SceneGroupIdGroup.class)
    @Min(value = 0,message = "组态id最小为0",groups = SceneGroupIdGroup.class)
    private Long sceneGroupId;
    @ApiModelProperty(value = "组态名,最长32字符", required = true)
    @NotEmpty(message = "组态名不能为空", groups = SceneNameGroup.class)
    @Length(min=6,max = 32,message = "组态名长度错误",groups = SceneNameGroup.class)
    @Pattern(regexp = "^[\\u4E00-\\u9FA5a-zA-Z0-9_-]{6,32}$", message = "组态文件名格式错误",groups = SceneNameGroup.class )
    private String name;
    @ApiModelProperty(value = "组态状态：0未发布，1未运行，2运行正常，3设备离线，4产生报警")
    private Integer state;
    @ApiModelProperty(value = "组态所有者id")
    private Long ownerId;
    @ApiModelProperty(value = "组态创建日期")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createDate;
    @NotNull(message = "组态描述不能为null", groups = DescriptionGroup.class)
    @Length(max = 128, message = "组态描述太长", groups = {DescriptionGroup.class})
    @ApiModelProperty(value = "组态描述,最长128字符",required = true)
    private String description;
    @ApiModelProperty(value = "组态文件大小")
    private Long size;
    @ApiModelProperty(value = "组态只读or读写：0只读，1读写", required = true)
    private Boolean readWrite;
    @ApiModelProperty(value = "组态地址,最长64字符")
    private String address;
    @ApiModelProperty(value = "组态地址在地图中的经度,组态运行的时候自动获取其中设备的地址作为组态地址，如果设备都没有地址，则为空,小数不超过6位")
    @Min(value = -180,message = "经度超过限制值")
    @Max(value = 180,message = "经度超过限制值")
    private Double longitude;
    @ApiModelProperty(value = "组态地址在地图中的维度,小数不超过6位")
    @Min(value = -90,message = "纬度超过限制值")
    @Max(value = 90,message = "纬度超过限制值")
    private Double latitude;
}
